﻿<?xml version="1.0" encoding="utf-8" ?>
<configuration>
  <system.serviceModel>
    <services>
      <service name="dasBlog.Storage.StorageBus">
        <!-- Remote Storage Bus Access -->
        <endpoint address="sb://connect.biztalk.net/services/clemensv/StorageBus"
            binding="relayBinding" bindingConfiguration="" contract="dasBlog.Storage.IStorageBus" />
        <!-- Relay WebGet/AJAX interface -->
        <endpoint address="sb://connect.biztalk.net/services/clemensv/feeds"
            binding="relayBinding" bindingConfiguration="" contract="dasBlog.Storage.IWebStorageBus" />
        <!-- Local WebGet/AJAX interface -->
        <endpoint address="http://localhost/storage/feeds"
            binding="webHttpBinding" bindingConfiguration="" contract="dasBlog.Storage.IWebStorageBus" />
      </service>
    </services>
    <!--Definitions for WCF clients-->
    <client>
      <endpoint address="http://foo/bar" binding="basicHttpBinding"
          bindingConfiguration="" contract="dasBlog.Storage.IStorageNode"
          name="remoteTextStorage" />
      <!--Cloud based text storage client-->
      <endpoint address="sb://connect.biztalk.net/services/dasBlogStorage/text/"
          binding="relayBinding" bindingConfiguration="" contract="dasBlog.Storage.IStorageNode"
          name="relayTextStorage" />
      <!--Cloud based stream storage client-->
      <endpoint address="sb://connect.biztalk.net/services/dasBlogStorage/stream/"
          binding="relayBinding" bindingConfiguration="" contract="dasBlog.Storage.IStorageNode"
          name="relayStreamStorage" />
      <!--Relay rendezvous point for events pub/sub -->
      <endpoint address="sb://connect.biztalk.net/services/personal.clemens.vasters.com/events/"
          binding="relayBinding" bindingConfiguration="" contract="dasBlog.Runtime.IEventNotification"
          name="relayEvents" />
      <!--Relay rendezvous point for log pub/sub -->
      <endpoint address="sb://connect.biztalk.net/services/personal.clemens.vasters.com/log/"
          binding="relayBinding" bindingConfiguration="" contract="dasBlog.Runtime.ILogNotification"
          name="relayLog" />
    </client>
  </system.serviceModel>
  <dasBlog.Storage>
    <!-- Encrypted Username/Password credentials for clients and providers -->
    <userNameCredentials>
      <userNameCredential name="flickr" username="flickrAccount" password="00-00-00-00-00-00-00-00" />
      <userNameCredential name="relay" username="relayAccount" password="00-00-00-00-00-00-00-00" />
      <userNameCredential name="silverlight" username="silverlightAccount" password="00-00-00-00-00-00-00-00" />
      <userNameCredential name="facebook" username="facebookAccount" password="00-00-00-00-00-00-00-00" />
      <userNameCredential name="linkedin" username="linkedinAccount" password="00-00-00-00-00-00-00-00" />
    </userNameCredentials>
    <!-- Definition of local and remote storage nodes -->
    <nodes>
      <!-- TextEntry provider on local SQLCE store -->
      <add name="textSql"
           provider="dasBlog.Storage.SqlServer.TextEntryProvider, dasBlog.Storage.SqlServer"
           initData="Data Source=|DataDirectory|\dasBlogStore.sdf"/>
      <!-- LogEntry provider on local SQLCE store -->
      <add name="logSql"
           provider="dasBlog.Storage.SqlServer.LogEntryProvider, dasBlog.Storage.SqlServer"
           initData="Data Source=|DataDirectory|\dasBlogStore.sdf"/>
      <!-- EventEntry provider on local SQLCE store -->
      <add name="eventSql"
           provider="dasBlog.Storage.SqlServer.EventEntryProvider, dasBlog.Storage.SqlServer"
           initData="Data Source=|DataDirectory|\dasBlogStore.sdf"/>
      <!-- TextEntry provider living up in the BizTalk Services cloud -->
      <add name="textCloud"
           client="relayTextStorage"
           clientCredential="relay"/>
      <!-- Stream provider on local file system -->
      <add name="streamNtfs"
           provider="dasBlog.Storage.Ntfs.StreamStorageProvider, dasBlog.Storage.Ntfs"
           initData=".\binaries"/>
      <!-- Stream provider in the cloud (redirects for stream retrieval) -->
      <add name="streamCloud"
           client="relayStreamStorage"
           clientCredential="relay"/>
      <!-- Local stream provider wrapping FlickR client (redirects for stream retrieval) -->
      <add name="picturesFlickR"
           provider="dasBlog.Storage.Flickr.PictureProvider, dasBlog.Storage.Flickr"
           clientCredential="flickr"/>
      <!-- Local contacts provider wrapping Facebook client -->
      <add name="contactsFacebook"
           provider="dasBlog.Storage.Facebook.ContactsProvider, dasBlog.Storage.Facebook"
           clientCredential="facebook"/>
      <!-- Local contacts provider wrapping LinkedIn client -->
      <add name="contactsLinkedIn"
           provider="dasBlog.Storage.LinkedIn.ContactsProvider, dasBlog.Storage.LinkedIn"
           clientCredential="linkedin"/>
      <!-- Local stream provider wrapping Silverlight stream storage (redirects for stream retrieval) -->
      <add name="videoSilverlight"
           provider="dasBlog.Storage.Silverlight.VideoProvider, dasBlog.Storage.Silverlight"
           clientCredential="silverlight"/>
      <!-- Local stream provider that does content-type-based routing to other providers  -->
      <add name="videoSplitter"
           provider="dasBlog.Storage.ContentTypeSplitterStreamProvider, dasBlog.Storage"
           initData="{video/*}=videoSilverlight,{*/*}=streamNtfs"/>
      <!--Contacts provider--> 
      <add name="contacts"
           provider="dasBlog.Storage.AggregateProvider, dasBlog.Storage"
           initData="contactsLinkedIn, contactsFacebook"/>
    </nodes>
    <!-- Definition of Uri-Layouts for various content shapes (blog, album, forum) -->
    <uriLayouts>
      <!-- Local SQL CE blog -->
      <uriLayout name="localBlog" writeRole="admin">
        <segment role="posts" node="textSql">
          <segment role="comments" node="textSql">
            <segment role="pictures" node="streamNtfs"/>
          </segment>
          <segment role="pictures" node="streamNtfs">
            <segment role="comments" node="textSql"/>
          </segment>
          <segment role="enclosures" node="videoSplitter">
            <segment role="comments" node="textSql"/>
          </segment>
          <segment role="trackings" node="logSql"/>
        </segment>
        <segment role="trackings" node="logSql"/>
        <segment role="events" node="eventSql" />
        <segment role="contacts" node="contacts" readRole="admin" />
      </uriLayout>
      <!-- Blog with cloud storage and local SQL CE log/events -->
      <uriLayout name="relayBlog" writeRole="admin">
        <segment role="posts" node="textRelay">
          <segment role="comments" node="textRelay">
            <segment role="pictures" node="streamRelay"/>
          </segment>
          <segment role="pictures" node="streamRelay">
            <segment role="comments" node="textRelay"/>
          </segment>
          <segment role="enclosures" node="streamRelay">
            <segment role="comments" node="textRelay"/>
          </segment>
          <segment role="trackings" node="logSql"/>
        </segment>
        <segment role="trackings" node="logSql"/>
        <segment role="events" node="eventSql"/>
      </uriLayout>
      <!-- FlickR album with local SQL CE comments -->
      <uriLayout name="flickrAlbum" writeRole="admin">
        <segment name="album" node="picturesFlickR">
          <segment role="comments" node="textSql"/>
        </segment>
      </uriLayout>
      <!-- Local SQL CE forum -->
      <uriLayout name="forum">
        <segment role="posts" node="textRelay" recursive="true">
          <segment role="pictures" node="streamRelay"/>
        </segment>
      </uriLayout>
    </uriLayouts>
    <!-- Storage Bus Scopes -->
    <storageBus>
      <add scope="personal.clemens.vasters.com" layout="localBlog"/>
      <add scope="discuss.clemens.vasters.com" layout="forum"/>
      <add scope="work.clemens.vasters.com" layout="remoteBlog"/>
    </storageBus>
  </dasBlog.Storage>
  <dasBlog.Runtime>
    <!-- 
         Existing dasBlog engine can only use one scope. The engine will
         inspect the shape of the scope's layout for compatibility. 
         Expected minimal layout shape is
             <segment role="posts">
               <segment role="comments"/>
               <segment role="trackings"/>
             </segment>
             <segment role="trackings"/>
             <segment role="events" />
        -->
    <blogDataService type="dasBlog.Runtime.StorageBusBlogDataProvider" 
                     contentLocation="personal.clemens.vasters.com"/>
    <!-- Log Service -->
    <logDataService type="dasBlog.Runtime.StorageBusLoggingProvider"
                    contentLocation="personal.clemens.vasters.com"/>
    <!-- Event fan-out -->
    <eventNotifications client="relayEvents" clientCredentials="relay" />
    <!-- Log fan-out -->
    <logNotifications client="relayLog" clientCredentials="relay" />
  </dasBlog.Runtime>
</configuration>
